package com.recsmile.sgs.entity;

import com.recsmile.sgs.listener.GameListener;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2016/8/29.
 */
public class SelfPlayerSimple extends PlayerSimple{

    private GameListener gameListener;

    private List<Card> cardsOnHand;
    private int attackLimit;// limit of attacks can be used in one TURN_DEAL, by
    // default 1
    private int attackUsed;// number of attacks already used this TURN_DEAL
    private volatile int wineLimit;// limit of wines can be used in on TURN_DEAL, by
    // default 1
    private volatile int wineUsed;// number of wines already used this TURN_DEAL
    private volatile boolean isWineUsed;// whether wine is used
    private volatile boolean wineEffective; // whether wine is currently effective

    // private settings

    // in-game interactive properties
    private List<Card> cardsUsedThisTurn;

    public SelfPlayerSimple(String nickname, int location) {
        super(nickname, location);

        init();
    }
    public void registerGameListener(GameListener listener) {
        gameListener = listener;
    }

    public GameListener getGameListener() {
        return gameListener;
    }


    private void init() {
        cardsOnHand = new ArrayList<Card>();

        cardsUsedThisTurn = new ArrayList<Card>();
        // init in-game interactive properties
        attackLimit = 1;
        attackUsed = 0;
        wineLimit = 1;
        wineUsed = 0;
        isWineUsed = false;
        wineEffective = false;
    }
    public List<Card> getCardsOnHand() {
        return cardsOnHand;
    }

    @Override
    public void addCard(Card card) {
        cardsOnHand.add(card);
        super.addCard(card);
    }

    @Override
    public void removeCardFromHand(Card card)  {
        if (!cardsOnHand.contains(card)) {
            throw new RuntimeException("removeCardFromHand: Card " + card + " is not on player's hand");
        }
        cardsOnHand.remove(card);
        super.removeCardFromHand(card);
    }
}
